package mk.gamemap.view.animeime
{
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.events.EventDispatcher;

	public class FrameAnime extends EventDispatcher implements IAnime
	{
		protected var mc:MovieClip
		private var _loop:int
		private var _name:String;
		private var _beginFrame:int;
		private var _totalFrames:int;
		function FrameAnime(mc:MovieClip,name:String,beginFrame:int,totalFrames:int):void{
			this.mc=mc;
			_name=name;
			_beginFrame=beginFrame
			_totalFrames=totalFrames;
		}
		
		public function get name():String{
			return _name
		}
		
		public function get source():DisplayObject{
			return mc;
		}
		
		public function get curFrame():int{
			return mc.currentFrame-_beginFrame+1
		}
		
		public function get totalFrames():int{
			return _totalFrames;
		}
		
		public function get isEnd():Boolean{
			return curFrame==totalFrames;
		}
		
		public function get loop():int{
			return _loop;
		}
		public function set loop(num:int):void{
			_loop=num;
		}
		
		public function prevFrame():void{
		}
		
		public function nextFrame():void{
			if (isEnd&&loop==0){
				reset()
			}else {
				
				mc.nextFrame();	
			}
			
		}
		
		public function reset():void{
			mc.gotoAndStop(_beginFrame);
			
		}
		
	}
}